package eclipse;
//斐波那契数
//1 1 2 3 5 8 13 21 34 55 89 144 ...

import java.util.Scanner;

public class Recursion1 {
    public static void main(String[] args) {
        System.out.println("请输入项数:");
        long num = fibonacci(new Scanner(System.in).nextInt());
        System.out.println(num);
    }

    private static long fibonacci(long n) {
        long a = 1;
        long b = 1;

        for(int i = 3; i <= n; i++){
            b = a + b;
            a = b - a;
        }
        return b;
    }

    /*private static int fibonacci(int n) {
        if(n == 1 || n == 2){
            return 1;
        }
        return fibonacci(n - 1) + fibonacci(n - 2);
    }*/


}
